<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>UserScript Integration - *NO* Matching Rule Test</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script src="assets/jsunittest.js" type="text/javascript"></script>
    <script src="_test_helper.js" type="text/javascript"></script>
    <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
  </head>
  <body>

    <div id="content">

      <div id="header">
        <h1>JavaScript unit test file</h1>
      </div>

      <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
      <div id="testlog"></div>
  
      <!-- Put sample/test html here -->
      <div id="sample">
      </div>
    </div>

    <script type="text/javascript">
    // <![CDATA[
      new Test.Unit.Runner({
        setup: function() {
          // Set the playing field by removing any link rel=canonical elements
          TestHelper.removeCanonicalLinkElements();
        },
    
        teardown: function() {
        },
        
        'test should not write a link rel=canonical element into the page when the userscript is evaluated and there is no rule matching this document': function() { with(this) {
          var canonicalLinkElements = TestHelper.getCanonicalLinkElements();
          assertEqual(0, canonicalLinkElements.length);
          
          TestHelper.insertCanonicalUrlUserScript();
          
          // We need to wait a very short amount of time: Just enough to ensure that when we check for the link element it's actually been inserted into the DOM
          wait(100, function() { 
            var canonicalLinkElements = TestHelper.getCanonicalLinkElements();
            assertEqual(0, canonicalLinkElements.length)
          });
        }}

      }); 
    // ]]>
    </script>
  </body>
</html>